package com.yourcom.proname.config;

import com.yourcom.proname.vo.CommonResVo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

@ControllerAdvice
public class ExceptionHandle {
    private final static Logger logger = LoggerFactory.getLogger(ExceptionHandle.class);

    @ResponseBody
    @ExceptionHandler(value = Exception.class)
    public CommonResVo handle(Exception e) {
        logger.error("统一异常处理：", e);
        return CommonResVo.fail(400, e.getMessage());
    }
}
